export default {
    data() {
        return {
            slideStart: [],
            moveTime: 0,
            refTarget: true
        };
    },
    onLoad() {},
    methods: {
        /**开始滑动 */
        touchstart(e) {
            /**记录开始滑动的时间 */

            this.slideStart = e.touches[0];
        },

        /**滑动 */
        touchmove(e) {
            let moveTime = new Date().getTime(); // 当前时间
            if (moveTime - this.moveTime <= 2000) {
                return;
            } else {
                this.moveTime = moveTime;
            }
            let slideStart = this.slideStart;
            let slideMove = e.touches[0];
            let startX = slideStart.pageX;
            let startY = slideStart.pageY;
            let moveEndX = slideMove.pageX;
            let moveEndY = slideMove.pageY;
            let X = moveEndX - startX;
            let Y = moveEndY - startY;

            if (Math.abs(Y) > Math.abs(X) && Y > 0) {
                // 从上向下滑
                console.log("top 2 bottom");
                this.pullRefresh();
            } else if (Math.abs(Y) > Math.abs(X) && Y < 0) {
                // 从下向上滑
                // console.log("bottom 2 top");
                // this.loadMore();
            }
        },
        /**下拉刷新 */
        pullRefresh(e) {

            this.refTarget = true;

            this.page = 1
            this.render();
        },
        /**上拉加载更多  暂时弃用 */
        loadMore(e) {
            if (this.more) {
                return;
            }
            this.render();
        },
    },
};